﻿using Clancy.Common;
using Clancy.Ui.ViewModels;
using System.Windows;
using System.Windows.Input;

namespace Clancy.Ui.Views
{
    /// <summary>
    /// Interaction logic for ZoneEditorWindow.xaml
    /// </summary>
    public partial class ZoneEditorWindow : Window
    {
        private ZoneEditorViewModel m_ViewModel;

        public ZoneEditorWindow()
        {
            InitializeComponent();

            m_ViewModel = DataContext as ZoneEditorViewModel;
            if (m_ViewModel != null)
            {
                m_ViewModel.SetDrawingCanvasPolygon(DrawingCanvasPolygon);
                m_ViewModel.SetDrawingCanvasZones(DrawingCanvasZones);
                m_ViewModel.Init();
            }
        }

        private void OnDrawingCanvasMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ClickCount == 2)
            {
                m_ViewModel.CreateNewZonePoint(e.GetPosition(FullCanvas).ToMotionZonePoint());
            }
        }
    }
}